/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.scaroo.injectedgallery.validators;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.regex.Pattern;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.xml.transform.Result;
import javax.xml.transform.Source;

import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;

/**
 *
 * @author alexandremazari
 */
public class FrenchPhoneNumberValidator implements ConstraintValidator<FrenchPhoneNumber, String> {

    private final static Pattern frenchPhoneNumberPattern = Pattern.compile("(0|0033|\\+33)[\\s-]*(\\d[\\s-]*){9}");//"\\d[\\s[:punct:]]*|\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*\\d[\\s[:punct:]]*");
    public void initialize(FrenchPhoneNumber constraintAnnotation) {
    }

    public boolean isValid(String value, ConstraintValidatorContext context) {
        return value == null ? false : frenchPhoneNumberPattern.matcher(value).matches();
    }



}

